﻿using System;
using System.Collections;
using System.Collections.Generic;
using Framework.Core.Reflection;

namespace Framework.Core.Recorder
{
    [Serializable]
    internal class DependencyParameters : IList<DependencyParameter>
    {
        private readonly IList<DependencyParameter> dependencyParameters;

        public DependencyParameters(IMethod method)
        {
            dependencyParameters = new List<DependencyParameter>();

            foreach (var argument in method.Arguments)
            {
                dependencyParameters.Add(new DependencyParameter(argument.Type, argument.Value));
            }
        }

        public IEnumerator<DependencyParameter> GetEnumerator()
        {
            return dependencyParameters.GetEnumerator();
        }

        public void Add(DependencyParameter item)
        {
            dependencyParameters.Add(item);
        }

        public void Clear()
        {
            dependencyParameters.Clear();
        }

        public bool Contains(DependencyParameter item)
        {
            return dependencyParameters.Contains(item);
        }

        public void CopyTo(DependencyParameter[] array, int arrayIndex)
        {
            dependencyParameters.CopyTo(array, arrayIndex);
        }

        public bool Remove(DependencyParameter item)
        {
            return dependencyParameters.Remove(item);
        }

        public int Count
        {
            get { return dependencyParameters.Count; }
        }

        public bool IsReadOnly
        {
            get { return dependencyParameters.IsReadOnly; }
        }

        public int IndexOf(DependencyParameter item)
        {
            return dependencyParameters.IndexOf(item);
        }

        public void Insert(int index, DependencyParameter item)
        {
            dependencyParameters.Insert(index, item);
        }

        public void RemoveAt(int index)
        {
            dependencyParameters.RemoveAt(index);
        }

        public DependencyParameter this[int index]
        {
            get { return dependencyParameters[index]; }
            set { dependencyParameters[index] = value; }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}